package com.neuqsoft.rd.citizen.thirdapp.sdk;

import com.neuqsoft.api.client.DefaultNeuqClient;
import com.neuqsoft.api.exception.NeuqApiException;
import com.neuqsoft.rd.citizen.thirdapp.sdk.dto.CodeReq;
import com.neuqsoft.rd.citizen.thirdapp.sdk.dto.PersonInfoDTO;
import com.neuqsoft.rd.citizen.thirdapp.sdk.dto.UserExInfoReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author baidh
 * @date 2020/12/02
 */
@Service
public class UserService {

    @Autowired
    DefaultNeuqClient client;

    /**
     * 一码通解码
     *
     * @param authCode
     * @return
     */
    public PersonInfoDTO beSwept(String authCode) throws NeuqApiException {
        CodeReq req = new CodeReq();
        req.setAuthCode(authCode);
        return client.postJson("https://service.neuqsoft.com/ggfw/citizen/gateway/openapi/api/v1/open/code", null, req, "", PersonInfoDTO.class);
    }

    /**
     * 用户信息查询
     *
     * @param uid
     * @param exInfo
     * @return
     */
    public Map userInfo(String uid, List<String> exInfo) throws NeuqApiException {
        UserExInfoReq req = new UserExInfoReq();
        req.setUid(uid);
        req.setExInfo(exInfo);
        return client.postJson("https://service.neuqsoft.com/ggfw/citizen/gateway/openapi/api/v1/open/user/info", null, req, "", Map.class);
    }

}
